from sqlalchemy import Column, INTEGER, DATETIME
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_dm import VARCHAR2, DATE, NUMBER

# 创建对象的基类
Base = declarative_base()

# 报告信息类
class SysReportModel(Base):
    # 模式名
    __table_args__ = {'schema': 'ESUNTEST'}
    # 表名
    __tablename__ = 'HX_SYS_REPORT'

    ID = Column(VARCHAR2(200), primary_key=True)
    COMPANY_NAME = Column(VARCHAR2(400))
    CREATE_USER = Column(VARCHAR2(100))
    CREATE_TIME = Column(DATETIME)
    FILE_UUID = Column(VARCHAR2(200))
    FILE_NAME = Column(VARCHAR2(200))
    FILE_URL_WORD = Column(VARCHAR2(200))
    IS_DELETE = Column(INTEGER)

    @classmethod
    def from_dict(cls, data):
        return cls(
            ID=data['ID'],
            COMPANY_NAME=data['COMPANY_NAME'],
            CREATE_USER=data['CREATE_USER'],
            CREATE_TIME=data['CREATE_TIME'],
            FILE_UUID=data['FILE_UUID'],
            FILE_NAME=data['FILE_NAME'],
            FILE_URL_WORD=data['FILE_URL_WORD'],
            IS_DELETE=data['IS_DELETE']
        )

    def to_dict(self):
        return {
            'ID': self.ID,
            'COMPANY_NAME': self.COMPANY_NAME,
            'CREATE_USER': self.CREATE_USER,
            'CREATE_TIME': self.CREATE_TIME,
            'FILE_UUID': self.FILE_UUID,
            'FILE_NAME': self.FILE_NAME,
            'FILE_URL_WORD': self.FILE_URL_WORD,
            'IS_DELETE': self.IS_DELETE
        }

